<div class="availablePoll">
    <g:form controller="vote" action="save">
        <g:hiddenField name="poll.id" value="${poll.id}" />
        <g:hiddenField name="voter.id" value="${loggedInUser?.id}" />
        <h3 class="left">${poll}</h3>
        <g:if test="${!expired}">
            <span class="expireText">
                <g:message code="poll.expires" default="Voting expires on" /> <g:formatDate date="${poll?.validUntil}" type="date" locale="${p.userLocale()}" />.<br />
                <g:if test="${!poll.publicPoll}">
                    <g:message code="poll.untilUserLimitReached" default="{0} vote(s) still needed." args="${[poll.votesNeeded()]}" />
                </g:if>
            </span>
        </g:if>
        <div class="clear"></div>
        <p>${poll.description} :<br /></p>
        <div class="radioOptions">
            <g:each var="option" status="i" in="${poll.options}">
                <g:if test="${poll.multivote}">
                    <g:checkBox id="option-${poll.id}-${i}" name="selection.id" value="${option.id}" checked="false" /> <label for="option-${poll.id}-${i}">${option}</label>
                </g:if>
                <g:else>
                    <g:radio id="option-${poll.id}-${i}" name="selection.id" value="${option.id}" /> <label for="option-${poll.id}-${i}">${option}</label>
                </g:else>
                <g:if test="${!poll.voteBeforeResults}">(<g:formatNumber number="${poll.distribution(option)}" locale="${p.userLocale()}" type="percent" maxFractionDigits="2" minFractionDigits="2" />)</g:if>
                <br />
            </g:each>
        </div>
        <g:if test="${!poll.isUserVoted(loggedInUser, request.getRemoteAddr())}">
            <g:submitButton name="vote" value="${g.message(code:'button.vote', default:'Vote for it')}" />
        </g:if>
        <g:else>
            <g:message code="alreadyVoted" default="I'm not sure how you did this, but you're already voted!" />
        </g:else>
    </g:form>
</div>